﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace JiaBao.Services.SalerService
{
    public class SalerService : ISalerService
    {
        string col = "合同编号,委托方姓名,手机,证件号码,地址,客户标识Z,拍卖会id";
        public DataTable GetByAucId(int Id)
        {
            try
            {
                return SqlHelper.ExecuteDataTable("select " + col + " from SalerAll where 拍卖会Id =@Id and isnull(合同编号,'') != ''", new SqlParameter("Id", Id)); ;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        public DataTable GetByAucIdAndOnlyNo(int Id)
        {
            try
            {
                return SqlHelper.ExecuteDataTable("select " + col + " from SalerAll where 拍卖会Id =@Id And 客户标识Z is null And isnull(合同编号,'') != ''", new SqlParameter("Id", Id));

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        public DataTable GetAllOnlyNo()
        {
            try
            {
                return SqlHelper.ExecuteDataTable("select " + col + " from SalerAll where 客户标识Z is null And isnull(合同编号,'') != ''");
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        public int ExecuteNonQuery(string sql, params SqlParameter[] parameter)
        {
            try
            {
                return SqlHelper.ExecuteNonQuery(sql, parameter);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        public int UpdateByAucId(int id)
        {
            try
            {
                return SqlHelper.StoredProcedureNonQuery("Z_Customer_Saler", new SqlParameter("@auc_id", id));
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        public DataTable GetByGUID(string guid)
        {
            try
            {
                return SqlHelper.ExecuteDataTable("select " + col + " from SalerAll where 客户标识Z =@Guid", new SqlParameter("Guid", guid));
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
    }
}
